package com.yanqu.road.server.manager.activity.daomu.pvp.task;

import com.yanqu.road.logic.helper.ActivityHelper;
import com.yanqu.road.server.manager.activity.daomu.DaoMuActivity;
import com.yanqu.road.server.manager.activity.daomu.DaoMuActivityMgr;
import com.yanqu.road.server.manager.activity.daomu.pvp.DaoMuActivityPvp;
import com.yanqu.road.utils.executor.GeneralTask;

import java.util.Map;

/**
 * 存活榜单
 */
public class DaoMuPvpAliveRankChangeTask extends GeneralTask {

    @Override
    public void doRun() {
        Map<Integer, DaoMuActivity> activityMap = DaoMuActivityMgr.getActivityMap();
        if (activityMap == null || activityMap.isEmpty()) {
            // 无活动
            return;
        }
        for (DaoMuActivity daoMuActivity : activityMap.values()) {
            try {
                if (!ActivityHelper.activityInTime(daoMuActivity.getDaoMuActivityConfig().getActivityInfo())) {
                    continue;
                }
                DaoMuActivityPvp activityPvp = daoMuActivity.getDaoMuActivityPvp();
                if (activityPvp != null) {
                    activityPvp.aliveRankChangeTask();
                }
            } catch (Exception e) {
                getLOGGER().error("aliveRankChangeTask error : ", e);
            }
        }
    }
}
